﻿using Confluent.Kafka;
using Microsoft.Extensions.Options;
using System;

namespace Cngot.Extensions.EventBus.Kafka
{
    [AttributeUsage(AttributeTargets.Method | AttributeTargets.Class, AllowMultiple = true)]
    public class MessageSubscribeAttribute : Attribute
    {
        internal string Topic;
        internal string Group;
        internal string Instance;
        internal bool EnableAutoCommit;
        internal AutoOffsetReset AutoOffsetReset;
        internal bool IsDelay = false;
        public MessageSubscribeAttribute(string topic, string group, string instance = null, bool enableAutoCommit = false, AutoOffsetReset autoOffsetReset = AutoOffsetReset.Earliest, bool isDelay = false)
        {
            this.Topic = topic;
            this.Group = group;
            this.Instance = instance ?? Options.DefaultName;
            this.EnableAutoCommit = enableAutoCommit;
            this.AutoOffsetReset = autoOffsetReset;
            this.IsDelay = isDelay;
        }
    }
}
